[ Intro ]   [ Lesson1 ]   [ Lesson2 ]   [ Lesson3 ]   [ Lesson4 ]   [ Lesson5 ]   [ Lesson6 ]   [ Lesson7 ]   [ Lesson8 ]

 


Animation

And then some firing scripts. Note that there are several stages of preparing a proper animation.

example

piece base ,body ,turret ,barrel ,flare;

Create()
{
hide flare;
}

FirePrimary()

{
show flare;
move barrel to z-axis [-2.4] speed [500];
sleep 100;
hide flare;
wait-for-move barrel along z-axis;
move barrel to z-axis [0] speed [3];
}

This is the script seen in Lesson 3, but with the addition of what actuons you should do to get it work. First of all, your unit should have a flare piece named flare that could look like a little explosion or just a brigt ball. Next, you need to hide it as soon as the unit is created. Real life weapons aren't walking around with permanent fire out of the barrels, right? Nevertheless, you show it again for a brief moment, just enough time for the eye to catch a glimpse of it.

 

example

piece base ,body ,turret ,barrel1 ,barrel2 ,flare1 ,flare2;

static-var alternate;


Create()
{
alternate = 1;
}

FirePrimary()
{
if (alternate == 1)
{
show flare1;
move barrel1 to z-axis [-2.4] speed [500];
sleep 100;
hide flare1;
wait-for-move barrel1 along z-axis;
move barrel1 to z-axis [0] speed [3];
}
if (alternate == 2)
{
show flare2;
move barrel2 to z-axis [-2.4] speed [500];
sleep 100;
hide flare2;
wait-for-move barrel2 along z-axis;
move barrel2 to z-axis [0] speed [3];
}
alternate = alternate + 1;
if (alternate == 3)
{
alternate = 1;
}
}

QueryPrimary(piecenum)
{
if (alternate == 1)
{
piecenum = flare1;
}
if (alternate == 2)
{
piecenum = flare2;
}
}

This time, we have two barrels and we want both to fire every other turn. So we set a static-var to 1, as in barrel1. If "alternate" is equal to 1, we run the animation for barrel1 and flare1. If it's equal to two, we run the same thing, but for the second barrel. After the eventual animation, we increase the value of "alternate" and if gets too large, we set it back to the lowest value again. To sum it up, every time the script runs through this, it will choose a different barrel than the previous. This script is easy to expand to fit in three or four or fiftynine barrels. It doesn't matter, since the basic function is the same.

Important: When having multi-barreled weapons, you will have to make sure that the query points alternate as well, or one barrel will recoil, but the shot will fly out of the other. That, quite frankly, sucks...

Congratulations, if you mastered this part, you can continue reading Lesson 3.


Storm